import { ReactNode } from "react";
import { observable, makeAutoObservable, runInAction } from "mobx";

class ModalStore {
  modalComponent: ReactNode;

  constructor() {
    makeAutoObservable(this, {
      modalComponent: observable.ref,
    })
  }

  setModalComponent = (modalComponent: ReactNode) => this.modalComponent = modalComponent;

  removeModalComponent = () => {
    setTimeout(() => runInAction(() => {
      this.modalComponent = null;
    }), 500)
  }
}

export const modalStore = new ModalStore();
